#ifndef JET2RGB_H
#define JET2RGB_H

#ifndef SELF_RGB_RULE //if you need to use self RGB struct,you should typedef it to RGB_S
typedef struct {
    int R,G,B,A;
}RGB_S;
#endif

inline RGB_S Jet2RGB(int val);

#endif

#ifndef JET2RGB_C
#define JET2RGB_C
#ifdef JET2RGB_IMPLEMENTATION

inline RGB_S Jet2RGB(int val){
    unsigned char r=0,g=0,b=0;
    if(val <= 31 && val >=0){
        b = 128 + val * 4;
    }else if(val == 32){
        b=255;
    }else if(val <=95 && val >=33){
        b=255;
        g=(val-33)*4+4;
    }else if(val == 96){
        b=254;
        g=255;
        r=2;
    }else if(val <=158 && val>=97){
        b=250-(4*(val-97));
        g=255;
        r=6+(4*(val-97));
    }else if(val == 159){
        b=1;
        g=255;
        r=254;
    }else if(val<=223 && val>=160){
        g=252 - (4*(val-160));
        r=255;
    }else if(val <=255 && val>=224){
        r=252 - (4*(val-224));
    }
    return (RGB_S){(unsigned char)r,(unsigned char)g,(unsigned char)b,255};
}
#endif
#endif
